#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int maxRemovals(string source, string pattern, vector<int>& targetIndices) {
        unordered_map<int, int> hash;
        for (int i : targetIndices) hash[i];
        int n = source.size(), m = pattern.size();
        vector<vector<int>> dp(n + 1, vector<int>(m + 1, INT_MIN));
        dp[0][0] = 0;

        for (int i = 1; i <= n; i++) {
            int exi = (hash.count(i - 1) == 0 ? 0 : 1);
            dp[i][0] = dp[i - 1][0] + exi;
            for (int j = 1; j <= m; j++) {
                dp[i][j] = dp[i - 1][j] + exi;
                if (source[i - 1] == pattern[j - 1]) dp[i][j] = max(dp[i - 1][j - 1], dp[i][j]);
            }
        }
        return dp[n][m];
    }
};